package com.atguigu.juc;


import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;


class MyThread implements Callable<Integer>
{
    @Override
    public Integer call() throws Exception
    {
        System.out.println("------come in");
        return 1024;
    }
}



public class CallableDemo
{
    public static void main(String[] args) throws ExecutionException, InterruptedException
    {

        FutureTask<Integer> futureTask2 = new FutureTask<>(new MyThread());
        FutureTask<Integer> futureTask = new FutureTask<>(()->{
            System.out.println("------come in==");
            return 10240;
        });

        Thread thread = new Thread(futureTask,"A");
        Thread thread2 = new Thread(futureTask2,"B");
        thread.start();
        thread2.start();

        System.out.println(futureTask.get());
        System.out.println(futureTask2.get());
    }
}